package com.gxnzd.communityelderly.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxnzd.communityelderly.commom.R;
import com.gxnzd.communityelderly.entity.City;
import com.gxnzd.communityelderly.mapper.CityMapper;
import com.gxnzd.communityelderly.service.CityService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: CityServiceImpl
 * Package: com.gxnzd.communityelderly.service.impl
 * Description:
 *
 * @Author 胡海峰
 * @Create 2024/10/5 17:51
 * @Version 1.0
 */
@Service
public class CityServiceImpl extends ServiceImpl<CityMapper, City> implements CityService {
    @Resource
    private CityMapper cityMapper;

    /**
     * level:0省，1市，2县
     * @param city
     * @return
     */
    @Override
    public R getSelectCity(City city) {
        LambdaQueryWrapper<City> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(City::getLevel,city.getLevel())
                .eq(City::getParentCode,city.getParentCode())
                .orderByAsc(City::getId);
        List<City> list =cityMapper.selectList(wrapper);
        return R.success(list);

    }
}
